cmake_minimum_required(VERSION 2.8)

set(EZSIFT ezsift)
project(${EZSIFT})

option(EZSIFT_BUILD_EXAMPLES "Build with examples" ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
    string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
endforeach()

set(EZSIFT_ROOT ${PROJECT_SOURCE_DIR}/../../)
set(EZSIFT_INCLUDE_DIR ${EZSIFT_ROOT}/include)
set(EZSIFT_SRC_DIR ${EZSIFT_ROOT}/src)

file(GLOB_RECURSE SRC RELATIVE ${PROJECT_SOURCE_DIR} "${EZSIFT_SRC_DIR}/*.cpp")
file(GLOB_RECURSE HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "${EZSIFT_SRC_DIR}/*.h" "${EZSIFT_INCLUDE_DIR}/*.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

add_library(${EZSIFT} ${SRC})
set_property(TARGET ${EZSIFT} PROPERTY POSITION_INDEPENDENT_CODE ON)

include_directories(
    ${EZSIFT_INCLUDE_DIR}
)

target_include_directories(${EZSIFT} PUBLIC ${EZSIFT_SRC_DIR})

if(EZSIFT_BUILD_EXAMPLES)
  add_subdirectory(${EZSIFT_ROOT}/examples ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples/)
endif()
